<#include "/admin/common/include/html_head.html"> <#include
"/admin/common/include/sysparam.html"> <#include
"/admin/common/include/pagination.html">



<div class="row-fluid">
	<div class="span12">
		<!-- BEGIN EXAMPLE TABLE PORTLET-->
		<div class="portlet box">

			<div class="portlet-title">
				<div class="caption">
					<h5>图片管理</h5>
				</div>
			</div>
			<div class="row-fluid">
				<div class="span12">
					<!-- BEGIN GALLERY MANAGER PORTLET-->
					<div class="portlet box blue">
						 
						<div class="portlet-body">
							<!-- BEGIN GALLERY MANAGER PANEL-->
							<div class="row-fluid">
								<div class="span4">
									 
								</div>
								<div class="span8">
							
									<div class="pull-right">
										<form id="imageSearchForm" onSubmit="return false;">
										<select data-placeholder="排序" class="chosen input-large"
											tabindex="-1" id="inputSort">
											<option value="0"></option>
											<option value="1">上传时间</option>
											<option value="2">作者</option>
											<option value="3">主题</option> 
										</select>
										</form>
										<div class="clearfix space5"></div>
										<button id="image_query_btn" class="btn blue">
											<i class="icon-search"></i>&nbsp;&nbsp;查询
										</button>
										<button id="image_upload_btn" class="btn blue">
											<i class="icon-plus"></i>&nbsp;&nbsp; 上传
										</button>
									 
									</div>
								</div>
								
							</div>
							<!-- END GALLERY MANAGER PANEL-->
							<hr class="clearfix" />
							<div class="row-fluid">
							<#list pageBean.result as nav > 
									<div class="span3">
									<div class="item">
										<a class="fancybox-button" data-rel="fancybox-button"
											title="Photo" href="${contextPath}${(nav.imageUrl)?if_exists}">
											<div class="zoom">
												<img  width="250" height="250" src="${contextPath}${(nav.imageUrl)?if_exists}" alt="Photo" />
												<div class="zoom-icon"></div>
											</div>
										</a>
										<div class="details"> 
										  	<a href="#" class="icon" name="image-edit" value="${nav.id}"><i class="icon-pencil"></i></a> <a
												href="#" class="icon" name="image-remove" value="${nav.id}"><i class="icon-remove"></i></a>
										</div>
									</div>
								</div> 
								</#list>  
							</div> 
							<@pagination searchFormId='imageSearchForm' pBean=pageBean />
						</div>
					</div>
				</div>
			</div>
			<!-- END EXAMPLE TABLE PORTLET-->
		</div>
	</div>
</div>

<script>
	jQuery(document).ready(function() { 
		
		tableAction.init({
			tableId : 'bannerTable',
			queryUrl : '${contextPath}/image/show.op', 
			editUrl : '${contextPath}/image/showEditForm.op', 
			editBtnId : 'image_upload_btn',
			queryBtnId : 'image_query_btn', 
			searchFormId : 'imageSearchForm',
			isPopEditForm : false 
		});
		App.init();
		Gallery.init();
		bindDeleteImage();
		bindEditImage(); 
	});
	
 
	
	function bindEditImage(){
		var editUrl = '${contextPath}/image/showEditForm.op';
		$("a[name='image-edit']").bind("click", function() { 
			var url = editUrl;
			var selectItems = $(this).attr("value"); 
			url += '?id=' + selectItems;
		    mainFrame.addContainer(url); 
		});
	}
	function bindDeleteImage(){
		var deleteUrl = '${contextPath}/image/delete.op';
		var queryUrl = '${contextPath}/image/show.op';
		$("a[name='image-remove']").bind("click", function() { 
			var url = deleteUrl;
			var selectItems = $(this).attr("value"); 
			common.alert({
				content : '是否删除选中项？',
				showAction : true,
				actionContent : '删除',
				actionFn : function() {
					var url = deleteUrl;  
					if(url.indexOf('?')>-1)
						url += '&selectItems=' + selectItems;
					else
						url += '?selectItems=' + selectItems;
					 
					ajax.syncJsonRequest({
						url : url,
						success : function(data) {
							if (!data || !data.success) {
								$('#'+_errZoneId).html(data.retinfo);
								$('#'+_errZoneId).show();
								common.alert({
									content : '删除失败！'
								});
							}
							if (data.success) {
								common.alert({
									content : data.retinfo,
									closeFn : function() {
									    mainFrame.addContainer(queryUrl); 
									}
								});
							}
						}
					});
				}
			});
		});
	}
</script>
<#include "/admin/common/include/html_bottom.html">
